package com.meteor.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.meteor.mapper.BookMapper;
import com.meteor.pojo.Book;
import com.meteor.service.BookService;
import com.meteor.pojo.BookDto;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Resource
    private BookMapper bookMapper;

    @Override
    public int insertBook(Book book) {
        return bookMapper.insertBook(book);
    }

    @Override
    public PageInfo<Book> selectBook(Integer pageNum, String bookName) {
        PageHelper.startPage(pageNum,5);
        List<Book> list = bookMapper.selectBook(bookName);
        PageInfo<Book> bookPageInfo = new PageInfo<>(list);
        return bookPageInfo;
    }

    @Override
    public List<Book> selectBookByTypeId(Integer typeId) {
        return bookMapper.selectBookByTypeId(typeId);
    }

    @Override
    public Book selectBookById(Integer id) {
        return bookMapper.selectBookById(id);
    }

    @Override
    public List<Book> selectBookRand() {
        return bookMapper.selectBookRand();
    }

    @Override
    public List<Book> selectBookByTime() {
        return bookMapper.selectBookByTime();
    }

    @Override
    public List<Book> selectBookByMark() {
        return bookMapper.selectBookByMark();
    }

    @Override
    public List<Book> selectBookBySell() {
        return bookMapper.selectBookBySell();
    }

    @Override
    public List<BookDto> selectBookByBookIds(int[] array) {
        return bookMapper.selectBookByBookIds(array);
    }

    @Override
    public Integer selectPrice(Integer[] arr) {
        return bookMapper.selectPrice(arr);
    }

    @Override
    public int updateCountByBookId(Book book) {
        return bookMapper.updateCountByBookId(book);
    }
}
